package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BHl7MedicineService;
import top.tangyh.lamp.care.entity.BHl7Medicine;
import top.tangyh.lamp.care.vo.query.MedicineQueryVO;
import top.tangyh.lamp.care.vo.result.PageOutputDTO;
import top.tangyh.lamp.care.vo.save.BHl7MedicineSaveVO;
import top.tangyh.lamp.care.vo.update.BHl7MedicineUpdateVO;
import top.tangyh.lamp.care.vo.result.BHl7MedicineResultVO;
import top.tangyh.lamp.care.vo.query.BHl7MedicinePageQuery;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 药物表
 * </p>
 *
 * @author zqb
 * @date 2024-08-09 16:23:52
 * @create [2024-08-09 16:23:52] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/medic")
@Tag(name = "药物管理接口")
public class BHl7MedicineController {
//    extends SuperController<BHl7MedicineService, Integer, BHl7Medicine
//            , BHl7MedicineSaveVO, BHl7MedicineUpdateVO, BHl7MedicinePageQuery, BHl7MedicineResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private final BHl7MedicineService bHl7MedicineService;

    @Operation(summary = "分页查询药物")
    @PostMapping("/page")
    public R<PageOutputDTO<BHl7Medicine>> selectPage(@RequestBody MedicineQueryVO queryVO) {
        PageOutputDTO<BHl7Medicine> page = bHl7MedicineService.selectPageByQuery(queryVO);
        return R.success(page);
    }

    @Operation(summary = "查询药物列表不分页")
    @PostMapping("/list")
    public R<List<BHl7Medicine>> selectList(@RequestBody MedicineQueryVO queryVO) {
        List<BHl7Medicine> page = bHl7MedicineService.selectListByQuery(queryVO);
        return R.success(page);
    }

    @Operation(summary = "添加药物")
    @PostMapping
    public R add(@RequestBody BHl7MedicineSaveVO inVO) {
        bHl7MedicineService.add(inVO);
        return R.success();
    }

    @Operation(summary = "修改药物")
    @PutMapping
    public R update(@RequestBody BHl7MedicineSaveVO inVO) {
        bHl7MedicineService.update(inVO);
        return R.success();
    }

    @Operation(summary = "删除药物")
    @DeleteMapping
    public R delete(Long id) {
        bHl7MedicineService.delete(id);
        return R.success();
    }


}


